﻿using Access.BLL;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
using YiWangTongBan.BLL;
using YiWangTongBan.Entity.dto;

namespace YiWangTongBan
{
    /// <summary>
    /// YWTB_WSX 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    [System.Web.Script.Services.ScriptService]
    public class NEWYWTB_WS : System.Web.Services.WebService
    {

        [WebMethod(MessageName = "querybjxx", Description = @"获取办件信息")]
        public void querybjxx(string incidentId, string applyNo, string businessType, string userId)
        {
            XiangYingEntity xiangYingEntity = new XiangYingEntity();
            if (businessType == "McsItemType.MuseumScreen")
            {
                KeJiGuanDPInput input = new KeJiGuanDPInput();
                input.incidentId = incidentId;
                input.applyNo = applyNo;
                input.businessType = businessType;
                input.userId = userId;

                xiangYingEntity = KeJiGuanDPBL(input);
            }
            else
            {
                xiangYingEntity.message = string.Format("不支持业务类型:{0}", businessType);
                xiangYingEntity.isSuccess = false;
                xiangYingEntity.code = 500;
            }

            YiWangTongBan.BLL.KeJiGuanDPBLL.KeJiGuanDPBLRespDto keJiGuanDPBLRespDto = new YiWangTongBan.BLL.KeJiGuanDPBLL.KeJiGuanDPBLRespDto();
            keJiGuanDPBLRespDto.code = xiangYingEntity.code;
            keJiGuanDPBLRespDto.success = xiangYingEntity.isSuccess;
            keJiGuanDPBLRespDto.incidentId = incidentId;
            PrintJson(JsonConvert.SerializeObject(keJiGuanDPBLRespDto));
        }



        KeJiGuanDPBLL keJiGuanDPBLL = new KeJiGuanDPBLL();

        /// <summary>
        /// 科技馆大屏
        /// </summary>
        /// <param name="keJiGuanDPInput"></param>
        [WebMethod(MessageName = "KeJiGuanDPBL", Description = @"科技馆大屏办理")]
        public XiangYingEntity KeJiGuanDPBL(KeJiGuanDPInput keJiGuanDPInput)
        {
            return keJiGuanDPBLL.KeJiGuanDPBL(keJiGuanDPInput);
        }

        [WebMethod(MessageName = "KeJiGuanDPSH", Description = @"科技馆大屏返回")]
        public IncidentStatusReturnEntity KeJiGuanDPSH(string body)
        {
            return keJiGuanDPBLL.KeJiGuanDPSH(body);
        }


        public static void PrintJson(string str)
        {
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
            HttpContext.Current.Response.Expires = 0;
            HttpContext.Current.Response.CacheControl = "no-cache";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            HttpContext.Current.Response.Charset = "utf-8";
            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(str);
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
            return;

        }
    }
}
